home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / program / n_b_v203.zip / HEXSTRS.DMO < prev    next >
Text File  |  1996-07-04  |  3KB  |  49 lines

  1. $if 0
  2.     ┌──────────────────────────╖                        PowerBASIC v3.20
  3.  ┌──┤          DASoft          ╟──────────────────────┬──────────────────╖
  4.  │  ├──────────────────────────╢    Copyright 1995    │ DATE: 1995-10-01 ╟─╖
  5.  │  │ FILE NAME   HEXSTRS .DMO ║          by          ╘════════════════─ ║ ║
  6.  │  │                          ║  Don Schullian, Jr.                     ║ ║
  7.  │  ╘══════════════════════════╝                                         ║ ║
  8.  │ A license is hereby granted to the holder to use this source code in  ║ ║
  9.  │ any program, commercial or otherwise,  without receiving the express  ║ ║
  10.  │ permission of the copyright holder and without paying any royalties,  ║ ║
  11.  │ as long as this code is not distributed in any compilable format.     ║ ║
  12.  │  IE: source code files, PowerBASIC Unit files, and printed listings   ║ ║
  13.  ╘═╤═════════════════════════════════════════════════════════════════════╝ ║
  14.    │                ....................................                   ║
  15.    ╘═══════════════════════════════════════════════════════════════════════╝
  16. $endif
  17.  
  18. '.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°
  19. ' ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° °
  20.  
  21. $INCLUDE "DAS-NB01.INC"
  22.  
  23. COLOR 7, 0
  24. CLS
  25. ? "┌───────────────────────────────────────────────────────────────────┘
  26. ? "│ fHexFormat$ ( HexOrDec$ )  check/format the incoming string
  27. ? "│ fHex2ASCii$ ( HexOrDec$ )  convert HEX and DEC strings to ASCII
  28. ? "│ fASCii2Hex$ ( ASCii$    )  convert ASCII strings to HEX
  29. ? "│ fASCii2Dec$ ( ASCii$    )  convert ASCII strings to DECIMAL
  30. ? "├──────────────────────────────────────────────────────────────────────┘
  31. ? "│ These functions reappeared while I was doing a small program to keep an
  32. ? "│ unofficial petty cash ledger and the customer had a couple of different
  33. ? "│ printers. I had to have a printer set-up string input field in the pgm.
  34. ? "│ and it was easier/better to have the customer use HEX values. Their use
  35. ? "│ is pretty straight forward and their output is predictable.
  36. ? "│ The thing to keep in mind is that fHex2ASCii process both HEX and DEC
  37. ? "│ strings so they can be mixed. The HEX values have a trailing <h>.
  38. ? "└────────────────────────────────────────────────────────────────────────┘
  39. ?
  40.  
  41. V$ = ",2,65,1bH,34,,"  : PRINT "     RAW: >>"; V$; "<<"  ' user input
  42. T$ = fHexFormat$( V$ ) : PRINT "FORMATED: >>"; T$; "<<"  ' cleaned up
  43.                          PRINT                           '
  44. A$ = fHex2ASCii$( T$ ) : PRINT "   ASCii: >>"; A$; "<<"  ' ASCII values
  45. H$ = fASCii2Hex$( A$ ) : PRINT "     HEX: >>"; H$; "<<"  ' HEX values
  46. D$ = fASCii2Dec$( A$ ) : PRINT " DECIMAL: >>"; D$; "<<"  ' DECIMAL values
  47.  
  48.  
  49.